//
//  HYOUStrategyCollectionViewCell.m
//  BestGift
//
//  Created by 温晓宇 on 15/12/30.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "HYOUStrategyCollectionViewCell.h"

@interface HYOUStrategyCollectionViewCell ()

@property(nonatomic, retain) UIImageView *image;
@property(nonatomic, retain) UILabel *name;

@end

@implementation HYOUStrategyCollectionViewCell
-(void)dealloc{
    [_image release];
    [_name release];
    [_model release];
    [super dealloc];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews{
    self.image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 70, 70 )];
//    self.image.backgroundColor = [UIColor redColor];
    self.image.layer.cornerRadius = 35;
    self.image.layer.masksToBounds = YES;
    [self.contentView addSubview:self.image];
    [_image release];
    
    self.name = [[UILabel alloc] initWithFrame:CGRectMake(0, 72, 70, 40)];
//    self.name.backgroundColor = [UIColor cyanColor];
    self.name.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.name];
    [_name release];
}
-(void)setModel:(HYOUStrategyCollectionModel *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    NSString *image = model.icon_url;
    NSURL *url = [NSURL URLWithString:image];
    [self.image sd_setImageWithURL:url];
    
    self.name.text = model.name;
}
@end
